﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NullSuicide.Steps
{
    public partial class SelectPlayers : Step
    {
        Players _players;

        public SelectPlayers()
        {
            InitializeComponent();
        }

        internal override void LoadData(Players players)
        {
            _players = players;

            dsPlayers.Tables["Players"].Clear();

            foreach (Player player in players.ListOfPlayers)
            {
                dsPlayers.Tables["Players"].Rows.Add(player.ID, player.Name, player.InRaid, player.Position);
            }            
        }

        internal override void SaveData()
        {
            foreach (DataRow currentRow in dsPlayers.Tables["Players"].Rows)
            {
                foreach (Player player in _players.ListOfPlayers)
                {
                    if (player.ID == (int)currentRow["ID"])
                    {
                        player.InRaid = (bool)currentRow["InRaid"];
                    }
                }
            }
        }
    }
}
